package com.chixing.day02;

public class StringDemo {
    public static void main(String[] args) {
        String result =  "https://search.51job.com";
                //workyear=02&cotype=99&degreefrom=03&jobterm=99&companysize=99&ord_field=0&dibiaoid=0&line=&welfare=
        String[] workYearArr = {"所有","在校生/应届生","1-3年","3-5年","5-10年","10年以上","无需经验"};
        String[] degreeArray = {"所有","初中及以下","高中/中专/大专","本科","硕士","博士","无学历要求"};
        String[] companyTypeArray = {"所有","国企","外资","上市公司","合资","民营企业","央企"};

        int workYearIndex = 0;  // 选择了 "在校生/应届生"
        int degreeIndex = 4;   // 选择了 "硕士"
        int companyTypeIndex = 2; // 选择了 "外资"

        /*for (int i=1;i<workYearArr.length;i++){
            if (i == workYear)
                result="workYear="+workYearArr[i];
        }
        for (int i=1;i<salaryArray.length;i++){
            if (i == salary)
                result=result+"salary="+salaryArray[i];
        }
        for (int i=1;i<degreeArray.length;i++){
            if (i == degree)
                result=result+"degree="+degreeArray[i];
        }
        for (int i=1;i<companyTypeArray.length;i++){
            if (i == companyType)
                result=result+"company"+companyTypeArray[i];
        }

        System.out.println(result);*/

        if (workYearIndex + degreeIndex + companyTypeIndex >0 )
            result+="?";

        if(workYearIndex >0 && workYearIndex <= workYearArr.length-1)
            result+= "workYear="+workYearArr[workYearIndex] +"&";

        if(degreeIndex >0 && degreeIndex <= degreeArray.length-1)
            result+= "degree="+degreeArray[degreeIndex]+"&";

        if(companyTypeIndex >0 && companyTypeIndex <= companyTypeArray.length-1)
            result+= "companyTypeArray="+companyTypeArray[companyTypeIndex] +"&";

        if(result.endsWith("&"))
            result=  result.substring(0,result.length()-1); // "hello"
        System.out.println(result);




        // 若以上选择了所有，则不传值
        workYearIndex = 1;
        degreeIndex = 0;
        companyTypeIndex = 2;

        result += "?workYear=在校生/应届生&companyType=外资";


    }


}
